package com.songlanyun.modules.userbankcard.service.impl;

import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.userbankcard.dao.BankCardIconDao;
import com.songlanyun.modules.userbankcard.entity.BankCardIconEntity;
import com.songlanyun.modules.userbankcard.service.BankCardIconService;


@Service("bankCardIconService")
public class BankCardIconServiceImpl extends ServiceImpl<BankCardIconDao, BankCardIconEntity> implements BankCardIconService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = MapUtil.getStr(params, "name");
        IPage<BankCardIconEntity> page = this.page(
                new Query<BankCardIconEntity>().getPage(params),
                new LambdaQueryWrapper<BankCardIconEntity>()
                        .eq(StringUtils.isNotBlank(name), BankCardIconEntity::getName, name)
                        .orderByAsc(BankCardIconEntity::getSort)
                        .orderByDesc(BankCardIconEntity::getCreateTime)
        );

        return new PageUtils(page);
    }

}